FROM php:7.4-fpm-alpine

# 更新为国内镜像
RUN set -eux && \
    sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
    apk update && \
    apk upgrade

# iconv support
RUN apk add --upgrade gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so

# update channel
RUN pecl channel-update pecl.php.net

# install deps
RUN apk add --no-cache g++ gcc make zip unzip autoconf zlib-dev libpng-dev libmemcached-dev libmcrypt-dev

# install exts
RUN docker-php-ext-install -j$(nproc) gd pdo_mysql mysqli sockets
RUN pecl install igbinary mcrypt lzf memcached swoole redis

# enable ext
RUN docker-php-ext-enable memcached igbinary mcrypt lzf swoole opcache redis

# composer
COPY composer-setup.php /usr/src/
RUN php /usr/src/composer-setup.php --install-dir=/usr/bin/ --filename=composer
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/